/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.gui;

import app.udp.ServerUdp;
import saci.*;

/**
 *
 * @author Pedro
 */
public class gui_servidor extends javax.swing.JFrame {

    private Servidor servidor;
    /**
     * Creates new form gui_servidor
     */
    public gui_servidor(Servidor servidor) {
        this.servidor = servidor;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        area_info = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        bt_on = new javax.swing.JButton();
        bt_off = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        area_info.setColumns(20);
        area_info.setRows(5);
        jScrollPane1.setViewportView(area_info);
        area_info.getAccessibleContext().setAccessibleName("");

        jLabel1.setText("INFO SERVIDOR:");

        bt_on.setText("Ativar");
        bt_on.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_onActionPerformed(evt);
            }
        });

        bt_off.setText("Desativar");
        bt_off.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_offActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(bt_on)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(bt_off)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_on)
                    .addComponent(bt_off))
                .addGap(11, 11, 11))
        );

        jLabel1.getAccessibleContext().setAccessibleName("info_server");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bt_onActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_onActionPerformed
        new Thread(new Runnable(){

            @Override
            public void run() {
                servidor.ligar();
            }            
        }).start();                        
    }//GEN-LAST:event_bt_onActionPerformed

    private void bt_offActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_offActionPerformed
        servidor.desligar();
      //  this.area_info.append("Servidor Desligado!");
    }//GEN-LAST:event_bt_offActionPerformed
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JTextArea area_info;
    private javax.swing.JButton bt_off;
    private javax.swing.JButton bt_on;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
